package vn.qnamuni.calendar.utils;

import android.util.Log;


public class GetDay {
	public static String convertDateToText(int m, int d, int y) {
		m+= 1;// delay 1 month
		String mo = "", da = "", ya="";
		if (m > 9) {
			mo = String.valueOf(m);
		} else {
			mo = "0" + String.valueOf(m);
		}
		if (d > 9) {
			da = String.valueOf(d);
		} else {
			da = "0" + String.valueOf(d);
		}
		if (y > 9) {
			ya = String.valueOf(y);
		} else {
			ya = "0" + String.valueOf(y);
		}
		String current = mo + "-" + da +"-"+ya;
		return current;
	}
	public static String addZero(String m) {
		if (m == null || m.equals("")) {
			return "00";
		} 
		if (m.length() == 1) {
			return "0" + m;
		}
		return m;
	}
	public static String convert(String date) {
		try {
			if (date == null || date.equals("null") ||date.equals(""))
				return "null";
			else {
				String[] m = date.split("-");
				return m[0].toString() + "-" + m[1].toString() +"-"+m[2].toString();
			}
		} catch (Exception e) {
			Log.v("GetDay Exception", e.getMessage());
		}
		return null;
	}

	public static Day getDay(String date) {
		try {
			if (date == null || date.equals("null") ||date.equals(""))
				return null;
			else {
				String[] m = date.split("-");
				return new Day(m[0], m[1],m[2]);
			}
		} catch (Exception e) {
			Log.v("GetDay Exception", e.getMessage());
		}
		return null;
	}
	
	public static Times getTimes(String date) {
		try {
			if (date == null || date.equals("null") ||date.equals(""))
				return null;
			else {
				String[] m = date.split(":");
				return new Times(m[0], m[1], m[2]);
			}
		} catch (Exception e) {
			Log.v("GetDay Exception", e.getMessage());
		}
		return null;
	}
	public static String getUI(String date) {
		if (date == null)
			return null;
		else {
			String[] m = date.split("-");
			String t = "";
			if (m[0].equals("01")) {
				t = "Jan " + m[1].toString();
				return t;
			}
			if (m[0].equals("02")) {
				t = "Feb " + m[1].toString();
				return t;
			}
			if (m[0].equals("03")) {
				t = "Mar " + m[1].toString();
				return t;
			}
			if (m[0].equals("04")) {
				t = "Apr " + m[1].toString();
				return t;
			}
			if (m[0].equals("05")) {
				t = "May " + m[1].toString();
				return t;
			}
			if (m[0].equals("06")) {
				t = "Jun " + m[1].toString();
				return t;
			}
			if (m[0].equals("07")) {
				t = "Jul " + m[1].toString();
				return t;
			}
			if (m[0].equals("08")) {
				t = "Aug " + m[1].toString();
				return t;
			}
			if (m[0].equals("09")) {
				t = "Sep " + m[1].toString();
				return t;
			}
			if (m[0].equals("10")) {
				t = "Oct " + m[1].toString();
				return t;
			}
			if (m[0].equals("11")) {
				t = "Nov " + m[1].toString();
				return t;
			}
			if (m[0].equals("12")) {
				t = "Dec " + m[1].toString();
				return t;
			}
			return "";
		}
	}
}
